<%@page contentType="text/html;charset=UTF-8" language="java" import="com.compuvest.web.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<%@ taglib uri="/WEB-INF/tld/bottom.tld" prefix="bottom" %>
<%@ taglib uri="/WEB-INF/tld/head.tld" prefix="head" %>

<jsp:useBean id="sb" class="MySQL" scope="application"/>
<jsp:useBean id="advertArray" class="AdvertArray" scope="application"/>
<jsp:useBean id="basket" class="Basket" scope="session"/>
<%
    Customer cust = basket.getCustomer();
    if(cust == null) {
	response.sendRedirect(application.getInitParameter("https") + "CustomerForm.jsp");
	return;
    }

    String vpassword = advertArray.getString(request.getParameter("vPassword"), cust.getPassword());
    String mode = request.getParameter("mode");
    if(mode != null && mode.equals("Submit")) {

	cust.setPassword(request.getParameter("Password"));

	cust.billing.setCompany(request.getParameter("billingCompany"));
	cust.billing.setFirstName(request.getParameter("billingFirstName"));
	cust.billing.setLastName(request.getParameter("billingLastName"));
	cust.billing.setAddress1(request.getParameter("billingAddress1"));
	cust.billing.setAddress2(request.getParameter("billingAddress2"));
	cust.billing.setCity(request.getParameter("billingCity"));
	cust.billing.setCountry(request.getParameter("billingCountry"));
	cust.billing.setState(request.getParameter("billingState"));
	cust.billing.setZip(request.getParameter("billingZip"));
	cust.billing.setZip4(request.getParameter("billingZip4"));
	cust.billing.setPhone(request.getParameter("billingPhone"));
	cust.billing.setCell(request.getParameter("billingCell"));
	cust.billing.setFax(request.getParameter("billingFax"));

	cust.shipping.setCompany(request.getParameter("shippingCompany"));
	cust.shipping.setFirstName(request.getParameter("shippingFirstName"));
	cust.shipping.setLastName(request.getParameter("shippingLastName"));
	cust.shipping.setAddress1(request.getParameter("shippingAddress1"));
	cust.shipping.setAddress2(request.getParameter("shippingAddress2"));
	cust.shipping.setCity(request.getParameter("shippingCity"));
	cust.shipping.setCountry(request.getParameter("shippingCountry"));
	cust.shipping.setState(request.getParameter("shippingState"));
	cust.shipping.setZip(request.getParameter("shippingZip"));
	cust.shipping.setZip4(request.getParameter("shippingZip4"));
	cust.shipping.setPhone(request.getParameter("shippingPhone"));
        cust.shipping.setCell(request.getParameter("shippingCell"));
        cust.shipping.setFax(request.getParameter("shippingFax"));

        String blind = request.getParameter("shipping");
        if(blind != null && "blind".equals(blind)) {
            basket.setBlindShipping(true);
            basket.setPackingSlip(request.getParameter("slip") != null ? true : false);
        }

        response.sendRedirect(application.getInitParameter("https") + "Payment.jsp");
        return;
    }
%>
<html>
<%@include file="/incl/head.html" %>

<body>

<table style='height:100%;'>

<tr height=100>
 <td>

<head:show />

 </td>
</tr>

<tr valign=top align=center>
 <td>

<br/>
<hr style='width:90%;'/>
<form name='Customer' action='<%= application.getInitParameter("https") + "CustomerEdit.jsp" %>' method='POST' onSubmit='return isFormDone(this);' enctype='application/x-www-form-urlencoded'>

<table width='80%'>
 <colgroup><col width='43%'><col width='14%'><col width='43%'></colgroup>
 <tr>
  <td colspan=2>
  <table id='cvfrm'>
   <colgroup><col width='45%'><col width='55%'></colgroup>
   <tr><th>Email :</th>
    <td><%= cust.getEmail() %></td>
   </tr>
   <tr><th>Password :</th>
    <td><input type=password name='Password' size=30 maxlength=15 value='<%= cust.getPassword() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
   <tr><th>Confirm Password :</th>
    <td><input type=password name='vPassword' size=30 maxlength=15 value='<%= vpassword %>'/></td>
   </tr>
   <tr><th>Reseller Certificate # : </th><td><%= cust.getResellerCode() %></td></tr>
   <tr><th>CompuvestB2B Account : </th><td><%= cust.getAccwareAccount() %></td></tr>
  </table>
  </td>
  <td>&nbsp;</td>
 </tr>

 <tr><td colspan=3>&nbsp;</td></tr>
 <tr align=center>
  <td class=bsm><b>Billing Address</b></td><td>&nbsp;</td><td class=bsm><b>Shipping Address</b></td>
 </tr>
 <tr valign=top>
  <td><p><font color=red>Note:</font> Your Billing address (address where credit card bank statement goes to) has to be entered with high
   accuracy. We use it to verify credit card information. If information is incorrect or incomplete, your order will not be shipped.</p>
  </td>
  <td colspan=2>&nbsp;</td>
 </tr>

 <tr valign=top>
  <td>
  <table id='cvfrm'>
   <colgroup><col width='35%'><col width='65%'></colgroup>
   <tr><th>Company Name :</th>
    <td><input type=text name='billingCompany' size=30 maxlength=40 value='<%= cust.billing.getCompany() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
   <tr><th>First Name :</th>
    <td><input type=text name='billingFirstName' size=30 maxlength=25 value='<%= cust.billing.getFirstName() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
   <tr><th>Last Name :</th>
    <td><input type=text name='billingLastName' size=30 maxlength=25 value='<%= cust.billing.getLastName() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
   <tr><th>Address1 :</th>
    <td><input type=text name='billingAddress1' size=30 maxlength=40 value='<%= cust.billing.getAddress1() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
   <tr><th>Address2 :</th>
    <td><input type=text name='billingAddress2' size=30 maxlength=40 value='<%= cust.billing.getAddress2() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
   <tr><th>Country :</th>
    <td>
    <select name='billingCountry'>
    <%= advertArray.getCountryList(cust.billing.getCountry()) %>
    </select>
    </td>
   </tr>
   <tr><th>City/Locality :</th>
    <td><input type=text name='billingCity' size=30 maxlength=30 value='<%= cust.billing.getCity() %>'/></td>
   </tr>
   <tr><th>State :</th>
    <td>
    <select name='billingState'>
     <option value=''/>
    <%= advertArray.getStateList(cust.billing.getState()) %>
    </select>
    </td>
   </tr>
   <tr><th>Postal/Zip Code :</th>
    <td>
     <input type=text name='billingZip' size=10 maxlength=10 value='<%= cust.billing.getZip() %>' onChange='this.value=toAlphaNumeric(this.value);'/> <b>-</b>
     <input type=text name='billingZip4' size=4 maxlength=4 value='<%= cust.billing.getZip4() %>' onChange='this.value=toAlphaNumeric(this.value);'/>
    </td>
   </tr>
   <tr><th>Phone :</th>
    <td><input type=text name='billingPhone' size=30 maxlength=20 value='<%= cust.billing.getPhone() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
   <tr><th>Cell :</th>
    <td><input type=text name='billingCell' size=30 maxlength=20 value='<%= cust.billing.getCell() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
   <tr><th>Fax :</th>
    <td><input type=text name='billingFax' size=30 maxlength=20 value='<%= cust.billing.getFax() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
  </table>
  </td>

  <td align=left valign=top id='nowrap'>
   <div class=ship2>
   <input type='radio' name='shipping' value='sasb' onClick='billtoshipp();'/>Shipping as Billing<br/>
   <input type='radio' name='shipping' value='blind' <%= basket.getBlindShipping() ? "checked=true" : "" %> onClick='blinds();'/>Blind Shipping<br/>
   &nbsp;&nbsp;&nbsp;<input type=checkbox name='slip' value='Y' <%= basket.getPackingSlip() ? "checked=true" : "" %> <%= basket.getBlindShipping() ? "" : "disabled=true" %> />Packing Slip
   </div>
  </td>

  <td>
  <table id='cvfrm'>
   <colgroup><col width='35%'><col width='65%'></colgroup>
   <tr><th>Company Name :</th>
    <td><input type=text name='shippingCompany' size=30 maxlength=40 value='<%= cust.shipping.getCompany() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
   <tr><th>First Name :</th>
    <td><input type=text name='shippingFirstName' size=30 maxlength=25 value='<%= cust.shipping.getFirstName() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
   <tr><th>Last Name :</th>
    <td><input type=text name='shippingLastName' size=30 maxlength=25 value='<%= cust.shipping.getLastName() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
   <tr><th>Address1 :</th>
    <td><input type=text name='shippingAddress1' size=30 maxlength=40 value='<%= cust.shipping.getAddress1() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
   <tr><th>Address2 :</th>
    <td><input type=text name='shippingAddress2' size=30 maxlength=40 value='<%= cust.shipping.getAddress2() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
   <tr><th>Country :</th>
    <td>
    <select name='shippingCountry'>
    <%= advertArray.getCountryList(cust.shipping.getCountry()) %>
    </select>
    </td>
   </tr>
   <tr><th>City/Locality :</th>
    <td><input type=text name='shippingCity' size=30 maxlength=30 value='<%= cust.shipping.getCity() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
   <tr><th>State :</th>
    <td>
    <select name='shippingState'>
     <option value=''/>
    <%= advertArray.getStateList(cust.shipping.getState()) %>
    </select>
    </td>
   </tr>
   <tr><th>Postal/Zip Code :</th>
    <td>
     <input type=text name='shippingZip' size=10 maxlength=10 value='<%= cust.shipping.getZip() %>' onChange='this.value=toAlphaNumeric(this.value);'/> <b>-</b>
     <input type=text name='shippingZip4' size=4 maxlength=4 value='<%= cust.shipping.getZip4() %>' onChange='this.value=toAlphaNumeric(this.value);'/>
    </td>
   </tr>
   <tr><th>Phone :</th>
    <td><input type=text name='shippingPhone' size=30 maxlength=20 value='<%= cust.shipping.getPhone() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
   <tr><th>Cell :</th>
    <td><input type=text name='shippingCell' size=30 maxlength=20 value='<%= cust.shipping.getCell() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
   <tr><th>Fax :</th>
    <td><input type=text name='shippingFax' size=30 maxlength=20 value='<%= cust.shipping.getFax() %>' onChange='this.value=toAlphaNumeric(this.value);'/></td>
   </tr>
  </table>
  </td>

 </tr>
</table>

<hr style='width:90%;'/>

<br/>
<input type='submit' name='mode' value='Submit'/>
</form>
<br/>

 </td>
</tr>

<tr height=35>
 <td>

<bottom:show />

 </td>
</tr>

</table>

</body>
<%@ include file="./incl/tracking.incl" %>
</html>
